<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        Array.prototype.distinct = function () {
            var ret = [];
            for (var i = 0; i < this.length; i++) {
                for (var j = i + 1; j < this.length;) {
                    if (this[i] === this[j]) {
                        ret.push(this.splice(j, 1)[0]);
                    } else {
                        j++;
                    }
                }
            }
            return ret;
        }
        console.log(['a', 'b', 'c', 'd', 'b', 'a', 'e'].distinct());

    </script>
</body>

</html>